package subject_set.top101;

/**
 * @author haomin
 * @date 2022/11/02 21:05
 **/
public class BM34 {
    public class Solution {
        boolean flag = true;
        TreeNode pre = null;
        public boolean isValidBST (TreeNode root) {
            inOrder(root);
            return flag;
        }
        private void inOrder(TreeNode root){
            if(root == null) return;
            inOrder(root.left);
            if(pre == null){
                pre = root;
            }else {
                if(pre.val > root.val) flag = false;
            }
            pre = root;
            inOrder(root.right);
        }
    }
}